package com.bardpub.weblite.ui 
{
	/**
	 * Copyright © 2010-2012, BardPub.com
	 * @fileName PageInfo.as
	 * @author LittleBard
	 * @version 1.0
	 * @date 2010/5/5
	 * @descrition 
	 * @others
	 * @history
	 */
	
	public class PageInfo
	{
		public var parent:PageInfo;
		public var pageName:String;
		public var pageTitle:String;
		public var pageURL:String;
		public var pageType:String;
		public var pageTarget:String;
		
		
		/**
		 * 创建 com.bardpub.weblite.ui.PageInfo 类的新实例
		 * @param	pageName 	页面名
		 * @param	pageTitle	页面标题
		 * @param	pageURL		页面URL
		 * @param	pageType	页面类型
		 */
		public function PageInfo(parent:PageInfo = null,
								 pageName:String = null, 
								 pageTitle:String = null, 
								 pageURL:String = null, 
								 pageType:String = null,
								 pageTarget:String = null) 
		{
			this.parent = parent;
			this.pageName = pageName;
			this.pageTitle = pageTitle;
			this.pageURL = pageURL;
			this.pageType = pageType;
			this.pageTarget = pageTarget;
		}
		
		public function clone():PageInfo
		{
			return new PageInfo(null, null,null, this.pageURL, null, null);
		}
		
		/**
		 * 比较两个PageInfo实例是否相同
		 * @param	info	要比较的 PageInfo 的实例
		 * @return
		 */
		public function contains(info:PageInfo):Boolean 
		{
			if (this.depth != info.depth)
			{
				return false;
			}
			else 
			{
				var pt:PageInfo = this;
				var pf:PageInfo = info;
				while (pt != null)
				{
					if (pt.pageName != pf.pageName)
					{
						return false;
					}
					pt = pt.parent;
					pf = pf.parent;
				}
			}
			return true;
		}
		
		/**
		 * 获取深度
		 */
		public function get depth():int 
		{
			var base:int = 1;
			var af:PageInfo = this;
			while (af.parent != null)
			{
				af = af.parent;
				base++;
			}
			return base;
		}
	}

}